<template>
  <div class="model" @close="isShowDialog = false">
    <div class="top">
      <i class="t-icon t-icon-dingwei4"></i>
      <span class="test"><b>图像定位</b></span>
    </div>
    <div class="gap"></div>
    <div class="bottom">
      <div class="bottom1">
        <div class="cancel">
          <i class="t-icon t-icon-cuowu3" @click="closeDialog"></i>
        </div>
        <div class="item-icon">
          <i class="t-icon t-icon-duanhengxian" style="position: absolute;margin-left: -60px"></i>
          <input type="file" ref="fileInput" style="display: none" @change="handleFileChange">
          <i class="t-icon t-icon-cloud-upload" @click="$refs.fileInput.click()"></i>
          <i class="t-icon t-icon-youjiantou2"></i>
          <i class="t-icon t-icon-mubiaojiansuo" @click="showDialog"></i>
          <Dialog v-model="dialogVisible"></Dialog>
          <i class="t-icon t-icon-youjiantou2"></i>
          <i class="t-icon t-icon-dingwei"></i>
          <i class="t-icon t-icon-duanhengxian" style="position: absolute;margin-left: 30px"></i>
        </div>
        <div>
          <span class="text1">上传图像</span>
          <span class="text1">开始检索</span>
          <span class="text1">位置显示</span>
        </div>
        <div class="setting">
          <el-menu
            :default-active="activeIndex"
            class="el-menu-demo"
            mode="horizontal"
            background-color="transparent"
            @select="handleSelect"
            text-color="white"
            active-text-color="#ffd04b"
          >
            <el-menu-item index="1">基本设置</el-menu-item>
            <el-menu-item index="2">参数设置</el-menu-item>
            <el-menu-item index="3">高级设置</el-menu-item>
          </el-menu>
        </div>
      </div>
      <div class="bottom2">
        <div class="border2">
          <div class="basic">
            <div style="display: flex">
              <v-select
                style="
                  color: #ade3b2;
                  margin-right: 30px;
                  margin-left: 30px;
                  margin-top: 15px;
                  text-align-last: center;
                "
                v-model="test"
                append-icon="mdi-close"
                label="基准图选择"
                :items="[
                  '街景',
                  '选项1',
                  '选项2',
                  '选项3',
                  '选项4',
                ]"
                variant="outlined"
              >
              </v-select>
              <v-select
                class="select"
                v-model="test1"
                append-icon="mdi-close"
                style="color: #ade3b2;
                       margin-top: 15px;"
                label="检索算法"
                :items="[
                  '算法1',
                  '算法2',
                  '算法3',
                  '算法4',
                ]"
                variant="outlined"
              ></v-select>
            </div>
            <i class="t-icon t-icon-tupian7" style="position: absolute;margin-top: -55px;margin-left:36px;"></i>
            <i class="t-icon t-icon-xiala2" style="position: absolute;margin-top: -55px;margin-left:120px;"></i>
            <i class="t-icon t-icon-sousuo" style="position: absolute;margin-top: -55px;margin-left:230px;"></i>
            <i class="t-icon t-icon-xiala2" style="position: absolute;margin-top: -55px;margin-left:315px;"></i>
          </div>
        </div>
        <div class="image-title">
          <i class="t-icon t-icon-tupian"></i>
          <span class="title">图片列表 数量:{{thumbnailAll.length}}</span>
          <el-tooltip class="item" effect="light" content="清空列表所有图像" placement="right-end">
          <i class="t-icon t-icon-qingkong" @click="thumbnailAll = []"></i></el-tooltip>
        </div>
        <div class="image_all">
          <div class="item" v-for="(l,i) in thumbnailAll" :key="i">
            <img :src="l.img" @click="handlerimg(l,i)" :style="thumbnailSize">
            <div class="right">
              <div :title="l.name">名称：{{ l.name }}</div>
              <div :title="l.path">路径：{{ l.path }}</div>
              <div :title="l.size">大小：{{ l.size }}</div>
            </div>
            <i class="t-icon t-icon-cuowu3" style="background-repeat: no-repeat" @click="thumbnailAll.splice(i,1)"></i>
          </div>
        </div>
      </div>
      <div class="isimg_fage" v-if="isImg">
        <img :src="imgs" @click="isImg = !isImg">
      </div>
    </div>
  </div>
</template>
<script>
import Dialog from './Sousuo.vue'

  export default {
    components: {
    Dialog
  },
    data() {
      return {
        isImg:false,
        imgs:'',
        dialogVisible: false,
        thumbnailAll:[],
        test: "街景",
        test1: "算法1",
        isShowDialog: true,
        activeIndex: '1',
        thumbnail: '', //缩略图
        fileName: '', //文件名
        filePath: '', //文件路径
        fileSize: '',//文件大小
        thumbnailSize: {
          width: '60px',
          height: '60px'
        },
      }
    },
    methods: {
      handlerimg(l,v){
       this.isImg = !this.isImg
        this.imgs = l.img
      },
      showDialog() {
      this.dialogVisible = true
    },
      closeDialog() {
        this.$emit('close'); // 触发关闭事件
      },
      handleFileChange() {
        // 存贮多个文件 以及名称路径
        let obj = {}
        const file = this.$refs.fileInput.files[0]
        // 路径
        const path = this.$refs.fileInput.value
        // 大小
        const size =(file.size / 1024).toFixed(1) + 'KB'
        // 获取缩略图
        const reader = new FileReader()
        reader.readAsDataURL(file)
        // 每次触发 获取每一个照片的路径 大小 和 图片 及 名称
        obj.name = file.name
        obj.size = size
        obj.path = path
        reader.onload= e =>{
          // 图片
          obj.img = e.target.result

        }
        // 组装数据 并一起添加到 总数居
        this.thumbnailAll.push(obj)


        // console.log(size,'size')
        // const reader = new FileReader()
        // reader.readAsDataURL(file)
        // reader.onload = (e) => {
        //   // this.thumbnail = e.target.result
        //  this.thumbnailAll.push(e.target.result)
        // }
        // this.fileName = file.name
        // this.filePath = path
        // this.fileSize = size
      }
    }}
</script>
<style lang="less" scoped>
 .isimg_fage{
      position: absolute;
      top:0;
      left: 0;
      bottom: 0;
      right: 0;
      width: 1300px;
      margin: auto;
 /*     overflow-y: auto;
      overflow-x: hidden;*/
      //transform: translateY(0%);
      height: 800px;
      img{
        width: 100%;
        height: 100%;
      }
    }
.image_all{
  display: flex;
  height: auto;
  flex-wrap: wrap;
  .item{
    flex: 1 100%;
    display: flex;
    justify-content: space-between;
    flex-wrap: nowrap;
    color:#fff;
    border: 1px solid;
    border-radius: 10px;
    font-size: 12px;
    background-color:rgba(82, 192, 192, 0.33);
    width: 360px;
    height: 80px;
    .right{
      //flex: 1 75%;
      display: flex;
      flex-wrap: wrap;
      div{
        text-overflow: ellipsis;
        overflow: hidden;
        word-break: break-all;
        white-space: nowrap;
        flex: 1 100%;
      }
    }
    img{
      flex: 1 20%;
      margin-right: 12px;
    }
  }
}
/deep/ .v-field{
  height: 38px;
  text-align: center;
  .v-select__selection-text{
    width: 43px;
    height: 25px;
    overflow: hidden;
    font-size: 14px;
  }
  option{
    text-align: center;
  }
  /deep/ .v-input{
    text-align-last: center;
    text-align: center;
  }
}
/deep/ .v-select__selection{
  margin-top: -4px;
}
/deep/ .v-field .v-field__field{
  padding-left: 28px;
  margin-bottom: 15px;
}
/deep/ .v-field .v-field__append-inner{
  display: none;
}
  .model {
    position: fixed;
    top: 500px;
    left: 130px;
    width: 25vw;
    height: 60vh;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    transform: translateY(-50%);
    z-index: 101;
    border-radius: 1px;
  }

  .top {
    height: 80px;
    width: 400px;
    background-color: rgba(43, 124, 124, 0.85);
    border-radius: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    color: white;
    font-size: 30px;
    font-family: Kaiti;
  }
  .gap {
    height: 10px;
    width: 100%;
    background-color: transparent;
  }

  .bottom {
    height: 350px;
    width: 400px;
    display: flex;
    flex-direction: column;
    align-items: center;
  }
  .bottom1 {
    height: 170px;
    width: 400px;
    display: flex;
    flex-direction: column;
    align-items: center;
    background-color: rgba(43, 124, 124, 0.85);
    border-top-left-radius: 13px; /* 左上角 */
    border-top-right-radius: 13px; /* 右上角 */
  }

  .bottom2 {
    //min-height: 300px;
    height: auto;
    width: 400px;
    border: 4px solid rgba(43, 124, 124, 0.85);
    border-bottom-left-radius: 13px; /* 左下角 */
    border-bottom-right-radius: 13px; /* 右下角 */
    background-color: rgba(32, 32, 32, 0.85);
  }
  .cancel {
    position: absolute;
    top: 94px;
    left: 372px;
  }

  .item-icon {
    margin-top: 40px;
  }

  .text1 {
    font-size: 14px;
    color: white;
    margin-right: 36px;
    margin-left: 23px;
    font-family: SimHei;
  }
  .setting {
    margin-top: 10px;
  }

  .el-menu {
    width: 400px;
    height: 60px;
    collapse: false;
    justify-content: space-around;
  }

  .el-menu-item.is-active {
    color: #6be03d !important;
    border-bottom-color: #6be03d !important;
    background-color: transparent !important;
  }

  .el-menu-item:hover {
    background-color: transparent !important;
  }

  .el-menu-item {
    width: 110px;
    height: 60px;
  }

  .border2 {
    background-color: rgba(32, 32, 32, 0.85);
    width: 393px;
    height: 70px;
    align-items: center;
  }

  .basic {
    background-color: rgba(82, 192, 192, 0.33);
    // border: 1px solid rgba(179, 183, 187, 0.84);
    width: 387px;
    height: 60px;
    display: inline-block;
    margin-left: 2px;
    margin-top: 5px;
    border-radius: 4px;
    justify-content: center;
  }

  .image-title {
    width: 394px;
    height: 30px;
    background-color: rgba(43, 124, 124, 0.85);
    display: flex;
    justify-content: start;
    margin-left: -1px;
    align-items: center;
  }
  .title {
    align-items: center;
    justify-content: center;
    color: white;
    font-family: Kaiti;
    font-size: 16px;
  }
  .image-select {
    border: 1px solid white;
    width: 100px;
    height: 30px;
    align-items: center;
    font-size: 10px;
    font-family: SimHei;
    color: white;
    margin-top: 5px;
    margin-left: 4px;
    border-radius: 4px;
  }

</style>
